<template>
	<view class="container">
		<image class="banner" :src="url+'/static/imgs/play-out-banner.png'" mode="aspectFill"></image>

		<form @submit="formSubmit">
			<view class="form">
				<view class="col form-group">
					<label for="money">打赏金额</label>
					<input name="price" type="digit" placeholder="请输入打赏金额" />
				</view>
				<view class="col form-group">
					<label for="money">打赏人数</label>
					<input name="num" type="number" placeholder="请输入打赏人数" />
				</view>
				<view class="col form-group">
					<label for="money">打赏留言</label>
					<textarea placeholder="请输入打赏留言" name="remark" />
					</view>
			</view>
			<button class="button" form-type="submit">发出打赏</button>
		</form>

	</view>
</template>
<style>
	.banner {
		width: 100%;
		height: 285rpx;
	}
	.form{
		margin: 18rpx 34rpx;
	}
	.form-group label{
		color: #333333;
		font-size: 30rpx;
		align-items: center;
		height: 80rpx;
		display: flex;
	}
	.form-group input,.form-group textarea{
		
		border:1rpx solid #BDBCBC;
		border-radius:10rpx;
		font-size: 28rpx;
		padding: 0rpx 36rpx;
	}
	.form-group input{
		height:86rpx;
	}
	.form-group textarea{
		padding: 20rpx 36rpx;
		height: 234rpx;
		width: 610rpx;
	}
	.button{
		position: fixed;
		bottom: 0;
		color: #fff;
		font-size: 30rpx;
		height:98rpx;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background:rgba(255,157,17,1);
		border-radius: 0;
	}
</style>
<script>
	var app=getApp();
	import http from "@/common/js/request.js"
	export default {
		data() {
			return {
				url:app.globalData.baseImgUrl,
			}
		},
		onLoad(option) {
			var that=this;
		},
		methods: {
			formSubmit: function(e) {
				var that=this;
				console.log(e)
				var price=e.detail.value.price;
				var num=e.detail.value.num;
				var remark=e.detail.value.remark;
				console.log(price,num,remark,that.storeid)
				if(price==''){
					uni.showToast({
						title: '请输入打赏金额',
						icon:"none",
						duration: 2000
					})
					return;
				}
				if(num==''){
					uni.showToast({
						title: '请输入打赏数量',
						icon:"none",
						duration: 2000
					})
					return;
				}
				if(remark==''){
					uni.showToast({
						title: '请输入打赏留言',
						icon:"none",
						duration: 2000
					})
					return;
				}
				http.post("/api/v1/store/reward_store",{
					store_id: app.globalData.storeId,
					price:price,
					num:num,
					remark:remark
				},function(res){
					if(res.state==1){
						uni.requestPayment({
						    provider: 'wxpay',
						    timeStamp:res.datas.timeStamp,
						    nonceStr: res.datas.nonceStr,
						    package: res.datas.package,
						    signType:res.datas.signType,
						    paySign: res.datas.paySign,
						    success: function (res) {
						        console.log('success:' + JSON.stringify(res));
								uni.navigateTo({
									url:"../playTourResult/playTourResult"
								})
						    },
						    fail: function (err) {
						        console.log('fail:' + JSON.stringify(err));
						    }
						});
					}else{
						uni.showModal({
							 title: '提示',
							 content:res.datas,
							 showCancel:false
						})
					}
					
				})
			},
		}
	}
</script>
